﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeSoft.Application.Bussiness;
using LeSoft.Util;
using LeSoft.Application.Entity;
using LeSoft.Application.Code;

namespace LeSoft.Application.Web.Areas.PropertyManage.Controllers
{
    public class WorkModuleInstanceController : MvcControllerBase
    {
        private WorkModuleInstanceBLL bll = new WorkModuleInstanceBLL();
        //
        // GET: /PropertyManage/WorkModuleInstance/
        #region 视图
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Form()
        {
            return View();
        }

        public ActionResult Model()
        {
            return View();
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 分页获取列表
        /// </summary>
        /// <param name="pagination">分页参数</param>
        /// <param name="queryJson">筛选条件</param>
        /// <returns></returns>
        [HttpGet]
        [HandlerAuthorize(PermissionMode.Ignore)]
        [HandlerAction(OperationType.GetList, "分页获取列表", "GetPageList")]
        public ActionResult GetPageList(Pagination pagination, string queryJson)
        {
            var watch = CommonHelper.TimerStart();
            var data = bll.GetPageList(pagination, queryJson);
            var JsonData = new
            {
                rows = data,
                total = pagination.total,
                page = pagination.page,
                records = pagination.records,
                costtime = CommonHelper.TimerEnd(watch)
            };
            return Content(JsonData.ToJson());
        }

        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="keyValue"></param>
        /// <returns></returns>
        [HttpGet]
        [HandlerAuthorize(PermissionMode.Ignore)]
        [HandlerAction(OperationType.GetForm, "获取实体", "GetForm")]
        public ActionResult GetForm(string keyValue)
        {
            return Content(bll.GetForm(keyValue).ToJson());
        }
        #endregion

        #region 提交数据
        /// <summary>
        /// 删除日志
        /// </summary>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        [HttpPost]
        [ValidateAntiForgeryToken]
        [AjaxOnly]
        [HandlerAction(OperationType.Delete, "删除日志", "RemoveForm")]
        public ActionResult RemoveForm(string keyValue)
        {
            try
            {
                bll.RemoveForm(keyValue);
                return Success("操作成功。");
            }
            catch (Exception e)
            {
                return Error("操作失败。" + e.Message);
            }
        }
        #endregion
 
    }
}
